package jvm;

class MyNumber {
    volatile int number = 0;

    public void changeNumber() {
        this.number = 10;
    }
}

public class Test {

    public static void main(String[] args) {
        MyNumber myNumber = new MyNumber();
        new Thread(() -> {
            System.out.println(Thread.currentThread().getName() + " is processing");
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            myNumber.changeNumber();
        }, "theadA").start();

        while (myNumber.number == 0) {
        }
        System.out.println("mission finished, myNumber = " + myNumber.number);
    }
}
